home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MemAllocators.h
-
- Version: Technology:
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __MEMALLOCATORS__
- #define __MEMALLOCATORS__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if FOR_SYSTEM8_PREEMPTIVE
- /*
- * NOTE: Callers of the MemAllocators API are gauranteed at least
- * kMemAllocatorAlignment_Minimum alignment of all allocated blocks.
- */
-
- enum {
- kMemAllocatorAlignment_Minimum = 2 /* (4 Byte Alignment Gaurantee) */
- };
-
- typedef struct OpaqueMemAllocatorRef* MemAllocatorRef;
- extern MemAllocatorRef xResidentAllocator;
- extern MemAllocatorRef xDefaultGlobalAllocator;
- extern MemAllocatorRef xDefaultAllocator;
- /*
- * Handle support
- */
- extern OSStatus MemNewHandle(MemAllocatorRef inAllocator, ByteCount inSize, Handle *outHandle);
-
- extern OSStatus MemNewHandleClear(MemAllocatorRef inAllocator, ByteCount inSize, Handle *outHandle);
-
- extern OSStatus MemDisposeHandle(Handle *ioHandle);
-
- extern OSStatus MemSizeHandle(ByteCount inSize, Handle inHandle);
-
- extern OSStatus MemGetHandleSize(Handle inHandle, ByteCount *outSize);
-
- /*
- * Fixed block support
- */
- extern OSStatus MemNewFixed(MemAllocatorRef inAllocator, ByteCount inSize, void **outMemory);
-
- extern OSStatus MemNewFixedClear(MemAllocatorRef inAllocator, ByteCount inSize, void **outMemory);
-
- /* inAlignment must be in the range 0..31 */
- extern OSStatus MemNewFixedAligned(MemAllocatorRef inAllocator, ByteCount inSize, UInt32 inAlignment, void **outMemory);
-
- /* inAlignment must be in the range 0..31 */
- extern OSStatus MemNewFixedAlignedClear(MemAllocatorRef inAllocator, ByteCount inSize, UInt32 inAlignment, void **outMemory);
-
- extern OSStatus MemDisposeFixed(MemAllocatorRef inAllocator, ByteCount inSize, void **ioMemory);
-
- /*
- * Convenience macros
- */
- #define MEMALLOC( ptrPtr) \
- MemNewFixed(xDefaultAllocator, sizeof(**ptrPtr), (void **)(ptrPtr))
- #define MEMALLOC_CLEAR(ptrPtr) \
- MemNewFixedClear(xDefaultAllocator, sizeof(**ptrPtr), (void **)(ptrPtr))
- #define MEMFREE(ptrPtr) \
- MemDisposeFixed(xDefaultAllocator, sizeof(**ptrPtr), (void **)(ptrPtr))
- /*
- * Variable block support
- */
- extern OSStatus MemNewVariable(MemAllocatorRef inAllocator, ByteCount inSize, void **outMemory);
-
- extern OSStatus MemNewVariableClear(MemAllocatorRef inAllocator, ByteCount inSize, void **outMemory);
-
- extern OSStatus MemDisposeVariable(MemAllocatorRef inAllocator, void **ioMemory);
-
- extern OSStatus MemGetVariableSize(MemAllocatorRef inAllocator, void *inMemory, ByteCount *outSize);
-
- extern OSStatus MemSizeVariable(MemAllocatorRef inAllocator, ByteCount inSize, void **ioMemory);
-
- /*
- * Debugging Support
- */
- extern OSStatus MemCheckAllocator(MemAllocatorRef inAllocator);
-
- extern OSStatus MemForceFailure(MemAllocatorRef inAllocator, OSStatus inForceFailure);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __MEMALLOCATORS__ */
-
-